import { createApp } from 'vue'
import pinia from './stores'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import './styles/index.scss'
import ElSvg from './components/SvgIcon/ElSvg'
import Category from './components/category/index.vue'
import './permission'
const app = createApp(App)
//定义全局组件
app.component('Category',Category)
import {useUserInfoStore} from './stores/userInfo'
// 按钮权限:方便一些 第一个参数：自定义指令名字  第二次参数：自定义指令钩子函数
app.directive('visite',{
  mounted(el,binding){
    if(!useUserInfoStore().buttonsList.includes(binding.value)){
      el.parentNode.removeChild(el)
    }
  }
})
//引入vue-echarts
import ECharts from 'vue-echarts'
import {use} from 'echarts/core'
import {
  CanvasRenderer
} from 'echarts/renderers'
import {
  BarChart
} from 'echarts/charts'
import {
  GridComponent,
  TooltipComponent
} from 'echarts/components'

use([
  CanvasRenderer,
  BarChart,
  GridComponent,
  TooltipComponent
]);
//全局组件
app.component('v-chart',ECharts)
//引入mock文件
import "./mock/mockServe"
ElSvg(app)
app.use(pinia)
  .use(router)
  .use(ElementPlus, {
    locale: zhCn,
  })
  .mount('#app')
